package com.mstore.dao;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.mstore.pojo.BalanceDeleteLog;

public class BalanceDeleteLogDao extends SuperDao {

	public void save(BalanceDeleteLog balanceDeleteLog) {
		super.save(balanceDeleteLog);
	}

	public Object findById(BalanceDeleteLog balanceDeleteLog) {
		String hql = "from BalanceDeleteLog where id=?";
		List<Object> objects = super.getObject(hql,
				new Object[] { balanceDeleteLog.getId() });
		if (objects.size() > 0) {
			return objects.get(0);
		}
		else {
			return null;
		}
	}

	public void updateById(BalanceDeleteLog balanceDeleteLog) {
		/*String sql = "update  log_balance_delete  set  create_time='"
				+ balanceDeleteLog.getCreateTime() + "'  where  id="
				+ balanceDeleteLog.getId();
		super.executeUpdate(sql);*/
		
		StringBuilder sb=new StringBuilder();
		String where="where";
		sb.append("update  log_balance_delete");
		String createTime=balanceDeleteLog.getCreateTime();
		
		if(StringUtils.isNotBlank(createTime)){
			sb.append(" set  create_time='");
			sb.append(createTime);
			sb.append("' ");
			sb.append(where);
			sb.append(" id=");
			sb.append(balanceDeleteLog.getId());
		}
		
		super.executeUpdate(sb.toString());
	}

}
